<script setup>
import {onMounted, ref} from "vue";
import banner1 from './images/banner1.jpg'
import banner2 from './images/banner2.jpg'
import banner3 from './images/banner3.jpg'
import banner4 from './images/banner4.jpg'
const bannerList = ref([
  {
    id: 1,
    img: banner1
  },
  {
    id: 2,
    img: banner2
  },
  {
    id: 3,
    img: banner3
  },
  {
    id: 4,
    img: banner4
  },
])

const screenWidth = ref(0)
const bannerHeight = ref(0)
onMounted(() => {
  screenWidth.value = window.innerWidth
  bannerHeight.value = 3 / 10 * screenWidth.value
  window.onresize = () => {
    screenWidth.value = window.innerWidth
    bannerHeight.value = 3 / 10 * screenWidth.value
  }
})
</script>

<template>
  <div class="home-banner">
    <el-carousel :interval="5000" :height="bannerHeight+'px'">
      <el-carousel-item v-for="item in bannerList" :key="item.id" style="text-align: center;">
        <img :src="item.img" alt=""/>
      </el-carousel-item>
    </el-carousel>
  </div>

</template>

<style scoped>
.home-banner {
  width: 100%;
  margin: 0 auto;
  border-left: 2px solid #ead9d7;
  border-right: 2px solid #ead9d7;
  background-image: url("@/assets/images/personal-bg.jpg");


  img {
    height: 100%;
    width: auto;
  }
}

</style>